//package com.keyinong.caizhengting.myfragement;
//
//import java.util.ArrayList;
//
//import org.apache.http.Header;
//import org.json.JSONArray;
//import org.json.JSONException;
//import org.json.JSONObject;
//
//import android.app.Activity;
//import android.content.Context;
//import android.content.SharedPreferences;
//import android.os.Bundle;
//import android.util.Log;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.view.Window;
//import android.widget.ImageButton;
//import android.widget.ListView;
//import android.widget.ScrollView;
//import android.widget.Toast;
//
//import com.handmark.pulltorefresh.library.PullToRefreshBase;
//import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
//import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
//import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
//import com.keyinong.caizhengting.R;
//import com.keyinong.caizhengting.Tools.HttpTools;
//import com.keyinong.caizhengting.Tools.NetWorkUtil;
//import com.keyinong.caizhengting.Tools.Utility;
//import com.keyinong.caizhengting.adapter.TeamAdapter;
//import com.keyinong.caizhengting.entity.TeamEntity;
//import com.loopj.android.http.JsonHttpResponseHandler;
//
///**团队订单*/
//
//public class TeamActivity extends Activity {
//	private TeamAdapter teamAdapter;
//	
//	/**订单列表*/
//	private ListView lv;
//	/** 刷新 */
//	private PullToRefreshScrollView pull_myorder;
//	/**份数*/
//	private int shuliang=0;
//	/**总价*/
//	private double zongjia;
//	/**返回*/
//	private ImageButton ib_back;
//	/**获得数据*/
//	ArrayList<TeamEntity> infolist;
//	HttpTools httptools=null;
//	String token = "";
//	int offset = 0;
//	int page = 3;
//	
//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		super.onCreate(savedInstanceState);
//		requestWindowFeature(Window.FEATURE_NO_TITLE);
//		setContentView(R.layout.activity_team);
//		SharedPreferences sp = getSharedPreferences("spReg",
//				Context.MODE_PRIVATE);
//		token = sp.getString("data", "");
//		pull_myorder=(PullToRefreshScrollView)findViewById(R.id.pull_team);
//		pull_myorder.setMode(Mode.BOTH);
//		pull_myorder.setOnRefreshListener(onrefresh);
//		lv=(ListView)findViewById(R.id.lv_team);
//		ib_back=(ImageButton)findViewById(R.id.ib_fanhui8);
//		ib_back.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				finish();
//			}
//		});
//		Team();
//	}
//
//	private void Team() {
//		infolist=new ArrayList<TeamEntity>();
//
//		//		Log.e("shi", "token---" + token);
//		if (httptools == null) {
//			httptools = new HttpTools(getApplicationContext());
//		}
//		httptools.teamorder(token, ""+page,""+ offset, new JsonTeam());	
//	}
//	public class JsonTeam extends JsonHttpResponseHandler {
//		@Override
//		public void onSuccess(int statusCode, Header[] headers,
//				JSONObject response) {
//			// TODO Auto-generated method stub
//			super.onSuccess(statusCode, headers, response);
//			try {
//				boolean code = response.getBoolean("code");
//				String msg = response.getString("msg");
//				if(code==true){
//					Log.i("info", "团队订餐---"+response.toString());
//					JSONArray array = response.getJSONArray("data");
//					for (int i = 0; i < array.length(); i++) {
//						JSONObject data = array.getJSONObject(i);
//						String id=data.getString("id");
//						String order_time=data.getString("order_time");
//						String paymodeid=data.getString("paymodeid");
//						String state=data.getString("state");
//						String name=data.getString("name");
//						String leader=data.getString("leader");
//						String total=data.getString("total");
//						JSONArray array2 = data.getJSONArray("details");
//							for(int j=0;j<array2.length();j++){
//								JSONObject detail = array2.getJSONObject(j);
//								String fenshu = detail.getString("amount");
//								String jiage = detail.getString("price");
//								zongjia += Integer.parseInt(fenshu)*Double.parseDouble(jiage);
//								shuliang += Integer.parseInt(fenshu);					
//							}
////							infolist.add(new TeamEntity(id, order_time, paymodeid, state, name,total, shuliang+""));
//							infolist.add(new TeamEntity(id, order_time, paymodeid, total, state, name, leader, shuliang+""));
//							zongjia=0.0;
//							shuliang=0;				
//					}
//				}else{
//					Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
//				}
//					teamAdapter=new TeamAdapter(getApplicationContext(), infolist);
//					lv.setAdapter(teamAdapter);
//					lv.setDivider(null);
//					Utility.setListViewHeightBasedOnChildren(lv);	
//				pull_myorder.onRefreshComplete();
//			} catch (JSONException e) {
//				e.printStackTrace();
//			}
//		}
//	}
//
//	// 上下拉刷新
//		private OnRefreshListener2<ScrollView> onrefresh = new OnRefreshListener2<ScrollView>() {
//
//			@Override
//			public void onPullDownToRefresh(
//					PullToRefreshBase<ScrollView> refreshView) {
//				offset = 0;
//				infolist.clear();
//				//				shuliang=0;
//				httptools.teamorder(token,  page + "", offset + "", 
//						new JsonTeam());
//				if (NetWorkUtil.isNetwork(getApplicationContext()) == false) {
//					Toast.makeText(getApplicationContext(),  "当前网络不可用", Toast.LENGTH_SHORT).show();
//					pull_myorder.onRefreshComplete();
//					return;
//				}
//			}
//
//			@Override
//			public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
//				offset += page;
//				//				shuliang=0;
//				httptools.teamorder(token, page + "", offset + "", 
//						new JsonTeam());
//				if (NetWorkUtil.isNetwork(getApplicationContext()) == false) {
//					pull_myorder.onRefreshComplete();
//					return;
//				}
//
//			}
//
//		};
//
//}
